package com.hspedu.newData.dmsxl.数组.二分查找;
/**
 * @Author: yh
 * @description: 
 * @CreateTime: 2025-05-26 
 * @Version: 1.0
 */

// todo
public class LC240搜索二维矩阵Ⅱ {

    public boolean searchMatrix(int[][] matrix, int target) {
        int m = matrix.length;
        int n = matrix[0].length;
        int x = 0;
        int y = n-1;
        while (x<m&&y>=0){
            if (matrix[x][y] == target){
                return true;
            } else if (matrix[x][y] > target) {
                --y;
            }else {
                ++x;
            }
        }
        return false;
    }

}
